#include "ti_msp_dl_config.h"

//电机调速
void Motor_SetSpeed(uint8_t motor_id, int32_t speed) 
{   
    uint32_t temp ;
    if(speed != 0)
    {
        temp = (speed*10) - 1;
        switch(motor_id) {
        case 1:
            DL_TimerA_setCaptureCompareValue(PWM_INST, temp, DL_TIMER_CC_0_INDEX);
            break;
        case 2:
            DL_TimerA_setCaptureCompareValue(PWM_INST, temp, DL_TIMER_CC_1_INDEX);
            break;
        case 3:
            DL_TimerA_setCaptureCompareValue(PWM_INST, temp, DL_TIMER_CC_2_INDEX);
            break;
        case 4:
            DL_TimerA_setCaptureCompareValue(PWM_INST, temp, DL_TIMER_CC_3_INDEX);
            break;
        }
    }
   if(speed == 0)
    {
        temp = 0;
        switch(motor_id) {
        case 1:
            DL_TimerA_setCaptureCompareValue(PWM_INST, temp, DL_TIMER_CC_0_INDEX);
            break;
        case 2:
            DL_TimerA_setCaptureCompareValue(PWM_INST, temp, DL_TIMER_CC_1_INDEX);
            break;
        case 3:
            DL_TimerA_setCaptureCompareValue(PWM_INST, temp, DL_TIMER_CC_2_INDEX);
            break;
        case 4:
            DL_TimerA_setCaptureCompareValue(PWM_INST, temp, DL_TIMER_CC_3_INDEX);
            break;
    }
    
    }
}